use utf8, our preferred encoding, in gbfputs.
authortsteven4 <tsteven4@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 16 Sep 2014 00:12:17 +0000 (00:12 +0000)
committertsteven4 <tsteven4@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 16 Sep 2014 00:12:17 +0000 (00:12 +0000)
gpsbabel/gbfile.cc
gpsbabel/reference/unicsv_encoding.csv [new file with mode: 0644]
gpsbabel/reference/unicsv_encoding.gpx [new file with mode: 0644]
gpsbabel/testo.d/unicsv.test

index a5ae1f1202e7387d87166926633bf3f5e3bd50dd..7a05780c714a9a395dcc7484afefe61d4197d6f2 100644 (file)
@@ -787,13 +787,8 @@ gbfputs(const char* s, gbfile* file)
 int
 gbfputs(const QString& s, gbfile* file)
 {
-  // Why is this Latin1() and not toUtf8()?  Becuase our string data is
-  // already utf8 in most of the "C" places and calling toUtf8() here would
-  // double encode them.
-  const char* qs = xstrdup(s.toLatin1().data());
-  unsigned int l = strlen(qs);
-  int rv =  gbfwrite(qs, 1, l, file);
-  xfree(qs);
+  QByteArray qs = s.toUtf8();
+  int rv =  gbfwrite(qs.constData(), 1, qs.size(), file);
   return rv;
 }
 
diff --git a/gpsbabel/reference/unicsv_encoding.csv b/gpsbabel/reference/unicsv_encoding.csv
new file mode 100644 (file)
index 0000000..708d012
--- /dev/null
@@ -0,0 +1,2 @@
+No,Latitude,Longitude,Name,Description,Notes\r
+1,40.000000,-105.000000,"α","β","ξ"\r
diff --git a/gpsbabel/reference/unicsv_encoding.gpx b/gpsbabel/reference/unicsv_encoding.gpx
new file mode 100644 (file)
index 0000000..fa9be38
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gpx version="1.0" creator="GPSBabel - http://www.gpsbabel.org" xmlns="http://www.topografix.com/GPX/1/0">
+  <time>2014-09-15T13:42:34.269Z</time>
+  <bounds minlat="40.000000000" minlon="-105.000000000" maxlat="40.000000000" maxlon="-105.000000000"/>
+  <wpt lat="40.000000000" lon="-105.000000000">
+    <name>α</name>
+    <cmt>β</cmt>
+    <desc>ξ</desc>
+  </wpt>
+</gpx>
index f84aae2745ded4b0c80b8a322669c5767e28b772..fe131328c11a7a66309fd3faf858d20d9618af9c 100644 (file)
@@ -18,3 +18,7 @@ compare ${TMPDIR}/gcunicsv-1.csv ${TMPDIR}/gcunicsv-2.csv
 # check header detection features
 gpsbabel -i unicsv,utc=0 -f ${REFERENCE}/headerdetection.unicsv -x transform,trk=wpt -o gpx,garminextensions -F ${TMPDIR}/headerdetection~unicsv.gpx
 compare ${TMPDIR}/headerdetection~unicsv.gpx ${REFERENCE}/extensiondata~unicsv.gpx
+
+# check default encoding, i.e. utf-8 in and out.
+gpsbabel -i gpx -f ${REFERENCE}/unicsv_encoding.gpx -o unicsv -F ${TMPDIR}/unicsv_encoding.csv
+compare ${TMPDIR}/unicsv_encoding.csv ${REFERENCE}/unicsv_encoding.csv